﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Gay.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
        protected void Application_BeginRequest()
        {
            //请求开始之前创建本次请求用到的DbContext
            //One DbContext Per Request
            //DbContext不是线程安全的
            //DbContextHelper.CreateDbContext();
            DbHelper.CreateDbContext();
        }

        protected void Application_EndRequest()
        {
            //本次请求结束销毁DbContext
            //DbContextHelper.FinishDbContext();
            DbHelper.FinishDbContext();
        }
    }
  
}
